#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }
}

mod front_of_house {

    pub mod hosting {
        pub fn add_to_waitlist() {}
    }

    pub mod serving {

        pub fn take_order() {}
    }
}

mod back_of_house {

    // 枚举类型
    pub enum Appetizer {
        Soup,
        Salad,
    }

    // 结构体
    pub struct Breakfast {
        pub toast: String,      // 公有的
        seasonal_fruit: String, // 私有的
    }

    impl Breakfast {
        // 定义个方法 返回一个面包
        pub fn summer(toast: &str) -> Breakfast {
            Breakfast {
                toast: String::from(toast),
                seasonal_fruit: String::from("peaches"),
            }
        }
    }

    fn fix_incorrect_order() {
        cook_order();

        // 调用父模块的方法
        super::server_order();
    }

    fn cook_order() {}
}

fn server_order() {}

pub fn eat() {
    // absolute path
    crate::front_of_house::hosting::add_to_waitlist();
    // relatvite path
    front_of_house::serving::take_order();
}

pub fn eat_at_restaurant() {
    let mut meal = back_of_house::Breakfast::summer("Rye");

    meal.toast = String::from("wheat");
    println!("I'd like {} toast please", meal.toast);

    // 访问枚举
    let order1 = back_of_house::Appetizer::Salad;
    let order2 = back_of_house::Appetizer::Soup;

    hosting::add_to_waitlist();
    hosting::add_to_waitlist();
    hosting::add_to_waitlist();
}
// used 用法, 貌似可以放到后面
use crate::front_of_house::hosting;

// 相对路径
// use front_of_house::hosting;
